package com.witherest.server.controller.api;

import com.witherest.server.common.bean.ResponseCode;
import com.witherest.server.vo.response.CommonResponse;
import com.witherest.server.vo.response.MainInfoResponse;
import com.witherest.server.vo.response.RoomInfo;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/{requestType}/main/info")
public class MainInfoController {
    private Logger logger = LoggerFactory.getLogger(MainInfoController.class);

    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public CommonResponse getMainInfo(@PathVariable String requestType, @RequestHeader(defaultValue = "") String token) throws Exception {
        logger.debug("Get Main Info In token value = {}", token);

        if (StringUtils.isEmpty(token))
            return new CommonResponse(ResponseCode.TOKEN_EMPTY, requestType);

        MainInfoResponse result = new MainInfoResponse(ResponseCode.SUCCESS, requestType);
        List<RoomInfo> roomList = new ArrayList<RoomInfo>();
        result.setUserNo("0");
        result.setUserName("Witherest");
        result.setUserComment("witherest와 함께 작심삼일은 이제 그만!");
        result.setUserImageSeq("0");
        result.setCreateRoomCount("1");
        result.setJoinRoomCount("1");
        result.setUserStarCount("5");

        RoomInfo room = new RoomInfo();
        room.setRoomNo("0");
        room.setRoomTitle("I Can't do it~~!!");
        room.setRoomContents("Maybe... I Can't don't smoking~~!");
        room.setStartDate("2013/05/10");
        room.setEndDate("2013/08/01");
        room.setRunWeekInfo("01010100");
        room.setRoomImageSeq("0");
        room.setChecked("true");
        room.setCheckedMemberCount("3");
        room.setTotalMemberCount("3");
        room.setRoomOwnerNo("0");
        roomList.add(room);

        room = new RoomInfo();
        room.setRoomNo("1");
        room.setRoomTitle("Shell we make money");
        room.setRoomContents("If you see the street, You can find a money on the road");
        room.setStartDate("2013/05/01");
        room.setEndDate("2013/06/20");
        room.setRunWeekInfo("10000000");
        room.setRoomImageSeq("1");
        room.setChecked("false");
        room.setCheckedMemberCount("2");
        room.setTotalMemberCount("4");
        room.setRoomOwnerNo("1");
        roomList.add(room);

        result.setRoomList(roomList);
        return result;
    }
}
